home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / sendmail / sendmail-5.65c+IDA-1.4.4.1 / src / RCS / stab.c,v < prev    next >
Encoding:
Text File  |  1991-06-25  |  3.3 KB  |  186 lines

  1. head    5.7;
  2. branch    5.7.0;
  3. access;
  4. symbols
  5.     RELEASE:5.7.0.2
  6.     BETA:5.7.0.2
  7.     UICSO:5.7.0
  8.     VANILLA:5.7;
  9. locks; strict;
  10. comment    @ * @;
  11.  
  12.  
  13. 5.7
  14. date    90.06.20.08.37.03;    author paul;    state Exp;
  15. branches
  16.     5.7.0.1;
  17. next    ;
  18.  
  19. 5.7.0.1
  20. date    91.02.17.22.55.01;    author paul;    state Exp;
  21. branches;
  22. next    5.7.0.2;
  23.  
  24. 5.7.0.2
  25. date    91.04.05.14.55.15;    author paul;    state Exp;
  26. branches;
  27. next    ;
  28.  
  29.  
  30. desc
  31. @@
  32.  
  33.  
  34.  
  35. 5.7
  36. log
  37. @5.64 Berkeley release
  38. @
  39. text
  40. @/*
  41.  * Copyright (c) 1983 Eric P. Allman
  42.  * Copyright (c) 1988 Regents of the University of California.
  43.  * All rights reserved.
  44.  *
  45.  * Redistribution and use in source and binary forms are permitted provided
  46.  * that: (1) source distributions retain this entire copyright notice and
  47.  * comment, and (2) distributions including binaries display the following
  48.  * acknowledgement:  ``This product includes software developed by the
  49.  * University of California, Berkeley and its contributors'' in the
  50.  * documentation or other materials provided with the distribution and in
  51.  * all advertising materials mentioning features or use of this software.
  52.  * Neither the name of the University nor the names of its contributors may
  53.  * be used to endorse or promote products derived from this software without
  54.  * specific prior written permission.
  55.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  56.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  57.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  58.  */
  59.  
  60. #ifndef lint
  61. static char sccsid[] = "@@(#)stab.c    5.7 (Berkeley) 6/1/90";
  62. #endif /* not lint */
  63.  
  64. # include "sendmail.h"
  65.  
  66. /*
  67. **  STAB -- manage the symbol table
  68. **
  69. **    Parameters:
  70. **        name -- the name to be looked up or inserted.
  71. **        type -- the type of symbol.
  72. **        op -- what to do:
  73. **            ST_ENTER -- enter the name if not
  74. **                already present.
  75. **            ST_FIND -- find it only.
  76. **
  77. **    Returns:
  78. **        pointer to a STAB entry for this name.
  79. **        NULL if not found and not entered.
  80. **
  81. **    Side Effects:
  82. **        can update the symbol table.
  83. */
  84.  
  85. # define STABSIZE    400
  86.  
  87. static STAB    *SymTab[STABSIZE];
  88.  
  89. STAB *
  90. stab(name, type, op)
  91.     char *name;
  92.     int type;
  93.     int op;
  94. {
  95.     register STAB *s;
  96.     register STAB **ps;
  97.     register int hfunc;
  98.     register char *p;
  99.     extern char lower();
  100.  
  101.     if (tTd(36, 5))
  102.         printf("STAB: %s %d ", name, type);
  103.  
  104.     /*
  105.     **  Compute the hashing function
  106.     **
  107.     **    We could probably do better....
  108.     */
  109.  
  110.     hfunc = type;
  111.     for (p = name; *p != '\0'; p++)
  112.         hfunc = (((hfunc << 7) | lower(*p)) & 077777) % STABSIZE;
  113.  
  114.     if (tTd(36, 9))
  115.         printf("(hfunc=%d) ", hfunc);
  116.  
  117.     ps = &SymTab[hfunc];
  118.     while ((s = *ps) != NULL && (strcasecmp(name, s->s_name) || s->s_type != type))
  119.         ps = &s->s_next;
  120.  
  121.     /*
  122.     **  Dispose of the entry.
  123.     */
  124.  
  125.     if (s != NULL || op == ST_FIND)
  126.     {
  127.         if (tTd(36, 5))
  128.         {
  129.             if (s == NULL)
  130.                 printf("not found\n");
  131.             else
  132.             {
  133.                 long *lp = (long *) s->s_class;
  134.  
  135.                 printf("type %d val %lx %lx %lx %lx\n",
  136.                     s->s_type, lp[0], lp[1], lp[2], lp[3]);
  137.             }
  138.         }
  139.         return (s);
  140.     }
  141.  
  142.     /*
  143.     **  Make a new entry and link it in.
  144.     */
  145.  
  146.     if (tTd(36, 5))
  147.         printf("entered\n");
  148.  
  149.     /* make new entry */
  150.     s = (STAB *) xalloc(sizeof *s);
  151.     bzero((char *) s, sizeof *s);
  152.     s->s_name = newstr(name);
  153.     makelower(s->s_name);
  154.     s->s_type = type;
  155.  
  156.     /* link it in */
  157.     *ps = s;
  158.  
  159.     return (s);
  160. }
  161. @
  162.  
  163.  
  164. 5.7.0.1
  165. log
  166. @ANSIfied.
  167. @
  168. text
  169. @d52 1
  170. a52 1
  171.     const char *name;
  172. d59 2
  173. a60 1
  174.     register const char *p;
  175. @
  176.  
  177.  
  178. 5.7.0.2
  179. log
  180. @Added RCS ID string
  181. @
  182. text
  183. @a22 1
  184. static char  rcsid[] = "@@(#)$Id$";
  185. @
  186.